package lily.phs.object.test;

import lily.phs.database.Constants;
import lily.phs.object.FirstPrenatalVisit;
import lily.phs.object.LastPostnatalCheck;
import lily.phs.object.PostnatalVisit;
import lily.phs.object.PrenatalVisit;


import android.database.Cursor;
import android.test.AndroidTestCase;

public class testPregnant extends AndroidTestCase implements Constants{

	public void testFirstPrenatalVisit(){
		FirstPrenatalVisit ht = new FirstPrenatalVisit(getContext());
		ht.setFipv_id(12345);
		ht.setFipv_date("2010-11-11");
		ht.setFipv_preg_week(3);
		ht.setFipv_age(28);
		ht.setFipv_husband_name("张先生");
		ht.setFipv_husband_age(28);
		ht.setFipv_husband_phone("15012345678");
		ht.setFipv_gravidity(2);
		ht.setFipv_vaginal_delivery_times(0);
		ht.setFipv_cesarean_section_times(0);
		ht.setFipv_last_menses(2);
		ht.setFipv_last_menses_date("不详");
		ht.setFipv_ycq("2011-7-23");
		ht.setFipv_past_history("2,3,8");
		ht.setFipv_past_history_other("其他疾病");
		ht.setFipv_family("2,3");
		ht.setFipv_family_other("家族史的其他疾病");
		ht.setFipv_personal("4,6");
		ht.setFipv_personal_other("残疾");
		ht.setFipv_has_gyneopration(1);
		ht.setFipv_gyneopration("");
		ht.setFipv_miscarry(0);
		ht.setFipv_dying_fetus(0);
		ht.setFipv_stillbirth(0);
		ht.setFipv_neonatal_death(1);
		ht.setFipv_birth_defect(0);
		ht.setFipv_height(153);
		ht.setFipv_weight(70.0f);
		ht.setFipv_bmt(31.1f);
		ht.setFipv_bloodpressure_high(120);
		ht.setFipv_bloodpressure_low(70);
		ht.setFipv_has_heart_abnormal(1);
		ht.setFipv_heart_abnormal("");
		ht.setFipv_has_lung_abnormal(2);
		ht.setFipv_lung_abnormal("肺部疾病");
		ht.setFipv_has_vulva_abnormal(1);
		ht.setFipv_vulva_abnormal("");
		ht.setFipv_has_vagina_abnormal(2);
		ht.setFipv_vagina_abnormal("阴道疾病");
		ht.setFipv_has_cervix_abnormal(1);
		ht.setFipv_cervix_abnormal("");
		ht.setFipv_has_uterus_abnormal(2);
		ht.setFipv_uterus_abnormal("子宫疾病");
		ht.setFipv_has_appendix_abnormal(1);
		ht.setFipv_appendix_abnormal("");
		ht.setFipv_hemoglobin(10.1f);
		ht.setFipv_wbc(10.2f);
		ht.setFipv_blood_platelet(10.3f);
		ht.setFipv_blood_other(10.4f);
		ht.setFipv_pro(10.5f);
		ht.setFipv_glu(10.6f);
		ht.setFipv_urine_ketone(10.7f);
		ht.setFipv_bld(10.8f);
		ht.setFipv_urine_other(10.9f);
		ht.setFipv_blood_type("AB");
		ht.setFipv_blood_rh("阴性");
		ht.setFipv_bs(11.0f);
		ht.setFipv_serum_cpt(11.1f);
		ht.setFipv_serum_ast(11.2f);
		ht.setFipv_blood_protein(11.3f);
		ht.setFipv_tbil(11.4f);
		ht.setFipv_dbil(11.5f);
		ht.setFipv_serum_creatinine(11.6f);
		ht.setFipv_bun(11.7f);
		ht.setFipv_vaginal_discharge("2,4");
		ht.setFipv_vaginal_other_discharge("其他分泌物");
		ht.setFipv_vagina_cleanness(3);
		ht.setFipv_surface_antigen("表面抗原");
		ht.setFipv_surface_antibody("表面抗体");
		ht.setFipv_e_antigen("e抗原");
		ht.setFipv_e_antibody("e抗体");
		ht.setFipv_core_antibody("核心抗体");
		ht.setFipv_syphilis_sero_test(1);
		ht.setFipv_hiv_test(2);
		ht.setFipv_brightness_mode("B超检查无异常");
		ht.setFipv_overall_access(1);
		ht.setFipv_overall_access_abnormal("");
		ht.setFipv_healthguide("1,3,6");
		ht.setFipv_healthguide_other("保健指导的其他意见");
		ht.setFipv_need_transfer(2);
		ht.setFipv_transfer_reason("查出患有肺部疾病");
		ht.setFipv_transfer_hospital("甘肃人民医院");
		ht.setFipv_next_visit_date("2011-2-13");
		ht.setFipv_doctor("李医生");
		ht.insertFirstPrenatalVisit();
		
		FirstPrenatalVisit ht1 = new FirstPrenatalVisit(getContext());
		ht1.selectFirstPrenatalVisit(12345);
		assertEquals(ht1.getFipv_date(),"2010-11-11");
		assertEquals(ht1.getFipv_preg_week(),3);
		assertEquals(ht1.getFipv_age(),28);
		assertEquals(ht1.getFipv_husband_name(),"张先生");
		assertEquals(ht1.getFipv_husband_age(),28);
		assertEquals(ht1.getFipv_husband_phone(),"15012345678");
		assertEquals(ht1.getFipv_gravidity(),2);
		assertEquals(ht1.getFipv_vaginal_delivery_times(),0);
		assertEquals(ht1.getFipv_cesarean_section_times(),0);
		assertEquals(ht1.getFipv_last_menses(),2);
		assertEquals(ht1.getFipv_last_menses_date(),"不详");
		assertEquals(ht1.getFipv_ycq(),"2011-7-23");
		assertEquals(ht1.getFipv_past_history(),"2,3,8");
		assertEquals(ht1.getFipv_past_history_other(),"其他疾病");
		assertEquals(ht1.getFipv_family(),"2,3");
		assertEquals(ht1.getFipv_family_other(),"家族史的其他疾病");
		assertEquals(ht1.getFipv_personal(),"4,6");
		assertEquals(ht1.getFipv_personal_other(),"残疾");
		assertEquals(ht1.getFipv_has_gyneopration(),1);
		assertEquals(ht1.getFipv_gyneopration(),"");
		assertEquals(ht1.getFipv_miscarry(),0);
		assertEquals(ht1.getFipv_dying_fetus(),0);
		assertEquals(ht1.getFipv_stillbirth(),0);
		assertEquals(ht1.getFipv_neonatal_death(),1);
		assertEquals(ht1.getFipv_birth_defect(),0);
		assertEquals(ht1.getFipv_height(),153);
		assertEquals(ht1.getFipv_weight(),70.0f);
		assertEquals(ht1.getFipv_bmt(),31.1f);
		assertEquals(ht1.getFipv_bloodpressure_high(),120);
		assertEquals(ht1.getFipv_bloodpressure_low(),70);
		assertEquals(ht1.getFipv_has_heart_abnormal(),1);
		assertEquals(ht1.getFipv_heart_abnormal(),"");
		assertEquals(ht1.getFipv_has_lung_abnormal(),2);
		assertEquals(ht1.getFipv_lung_abnormal(),"肺部疾病");
		assertEquals(ht1.getFipv_has_vulva_abnormal(),1);
		assertEquals(ht1.getFipv_vulva_abnormal(),"");
		assertEquals(ht1.getFipv_has_vagina_abnormal(),2);
		assertEquals(ht1.getFipv_vagina_abnormal(),"阴道疾病");
		assertEquals(ht1.getFipv_has_cervix_abnormal(),1);
		assertEquals(ht1.getFipv_cervix_abnormal(),"");
		assertEquals(ht1.getFipv_has_uterus_abnormal(),2);
		assertEquals(ht1.getFipv_uterus_abnormal(),"子宫疾病");
		assertEquals(ht1.getFipv_has_appendix_abnormal(),1);
		assertEquals(ht1.getFipv_appendix_abnormal(),"");
		assertEquals(ht1.getFipv_hemoglobin(),10.1f);
		assertEquals(ht1.getFipv_wbc(),10.2f);
		assertEquals(ht1.getFipv_blood_platelet(),10.3f);
		assertEquals(ht1.getFipv_blood_other(),10.4f);
		assertEquals(ht1.getFipv_pro(),10.5f);
		assertEquals(ht1.getFipv_glu(),10.6f);
		assertEquals(ht1.getFipv_urine_ketone(),10.7f);
		assertEquals(ht1.getFipv_bld(),10.8f);
		assertEquals(ht1.getFipv_urine_other(),10.9f);
		assertEquals(ht1.getFipv_blood_type(),"AB");
		assertEquals(ht1.getFipv_blood_rh(),"阴性");
		assertEquals(ht1.getFipv_bs(),11.0f);
		assertEquals(ht1.getFipv_serum_cpt(),11.1f);
		assertEquals(ht1.getFipv_serum_ast(),11.2f);
		assertEquals(ht1.getFipv_blood_protein(),11.3f);
		assertEquals(ht1.getFipv_tbil(),11.4f);
		assertEquals(ht1.getFipv_dbil(),11.5f);
		assertEquals(ht1.getFipv_serum_creatinine(),11.6f);
		assertEquals(ht1.getFipv_bun(),11.7f);
		assertEquals(ht1.getFipv_vaginal_discharge(),"2,4");
		assertEquals(ht1.getFipv_vaginal_other_discharge(),"其他分泌物");
		assertEquals(ht1.getFipv_vagina_cleanness(),3);
		assertEquals(ht1.getFipv_surface_antigen(),"表面抗原");
		assertEquals(ht1.getFipv_surface_antibody(),"表面抗体");
		assertEquals(ht1.getFipv_e_antigen(),"e抗原");
		assertEquals(ht1.getFipv_e_antibody(),"e抗体");
		assertEquals(ht1.getFipv_core_antibody(),"核心抗体");
		assertEquals(ht1.getFipv_syphilis_sero_test(),1);
		assertEquals(ht1.getFipv_hiv_test(),2);
		assertEquals(ht1.getFipv_brightness_mode(),"B超检查无异常");
		assertEquals(ht1.getFipv_overall_access(),1);
		assertEquals(ht1.getFipv_overall_access_abnormal(),"");
		assertEquals(ht1.getFipv_healthguide(),"1,3,6");
		assertEquals(ht1.getFipv_healthguide_other(),"保健指导的其他意见");
		assertEquals(ht1.getFipv_need_transfer(),2);
		assertEquals(ht1.getFipv_transfer_reason(),"查出患有肺部疾病");
		assertEquals(ht1.getFipv_transfer_hospital(),"甘肃人民医院");
		assertEquals(ht1.getFipv_next_visit_date(),"2011-2-13");
		assertEquals(ht1.getFipv_doctor(),"李医生");
		
		ht1.delectFirstPrenatalVisit(12345);
		Cursor cursor = getContext().getContentResolver().query(CONTENT_URI_TB16, null, FIPV_COLUMN1+"="+12345+"", null, null);
		assertEquals(0, cursor.getCount());
	}
	
	public void testPrenatalVisit(){
		PrenatalVisit ht = new PrenatalVisit(getContext());
		ht.setPrvi_id(12345);
		ht.setPrvi_date("2011-5-21");
		ht.setPrvi_times(3);
		ht.setPrvi_preg_week(25);
		ht.setPrvi_selftalk("食欲不好");
		ht.setPrvi_weight(150.0f);
		ht.setPrvi_palace_height(30);
		ht.setPrvi_chest_measure(150);
		ht.setPrvi_fetal_position("中间");
		ht.setPrvi_fetal_heartrate(50);
		ht.setPrvi_bloodpressure_high(130);
		ht.setPrvi_bloodpressure_low(80);
		ht.setPrvi_hgb(16.1f);
		ht.setPrvi_urine_protein(16.2f);
		ht.setPrvi_other_assitest("其他的检查项目");
		ht.setPrvi_is_abnormal(2);
		ht.setPrvi_abnormal("感冒");
		ht.setPrvi_guide("1,2,7");
		ht.setPrvi_other_guide("其他指导");
		ht.setPrvi_need_transfer(1);
		ht.setPrvi_transfer_reason("");
		ht.setPrvi_transfer_hospital("");
		ht.setPrvi_next_visit_date("2011-6-10");
		ht.setPrvi_doctor("李医生");
		ht.insertPrenatalVisit();
		
		PrenatalVisit ht1 = new PrenatalVisit(getContext());
		ht1.selectPrenatalVisit(12345,3);
		assertEquals(ht1.getPrvi_date(),"2011-5-21");
		assertEquals(ht1.getPrvi_times(),3);
		assertEquals(ht1.getPrvi_preg_week(),25);
		assertEquals(ht1.getPrvi_selftalk(),"食欲不好");
		assertEquals(ht1.getPrvi_weight(),150.0f);
		assertEquals(ht1.getPrvi_palace_height(),30);
		assertEquals(ht1.getPrvi_chest_measure(),150);
		assertEquals(ht1.getPrvi_fetal_position(),"中间");
		assertEquals(ht1.getPrvi_fetal_heartrate(),50);
		assertEquals(ht1.getPrvi_bloodpressure_high(),130);
		assertEquals(ht1.getPrvi_bloodpressure_low(),80);
		assertEquals(ht1.getPrvi_hgb(),16.1f);
		assertEquals(ht1.getPrvi_urine_protein(),16.2f);
		assertEquals(ht1.getPrvi_other_assitest(),"其他的检查项目");
		assertEquals(ht1.getPrvi_is_abnormal(),2);
		assertEquals(ht1.getPrvi_abnormal(),"感冒");
		assertEquals(ht1.getPrvi_guide(),"1,2,7");
		assertEquals(ht1.getPrvi_other_guide(),"其他指导");
		assertEquals(ht1.getPrvi_need_transfer(),1);
		assertEquals(ht1.getPrvi_transfer_reason(),"");
		assertEquals(ht1.getPrvi_transfer_hospital(),"");
		assertEquals(ht1.getPrvi_next_visit_date(),"2011-6-10");
		assertEquals(ht1.getPrvi_doctor(),"李医生");
		
		ht1.delectPrenatalVisit(12345,3);
		Cursor cursor = getContext().getContentResolver().query(CONTENT_URI_TB17, null, PRVI_COLUMN1+"="+12345+"", null, null);
		assertEquals(0, cursor.getCount());
	}
	
	public void testPostnatalVisit(){
		PostnatalVisit ht = new PostnatalVisit(getContext());
		ht.setPovi_id(12345);
		ht.setPovi_date("2011-8-3");
		ht.setPovi_body_temprature(37.0f);
		ht.setPovi_ordinary_healthstatus("一般健康状况");
		ht.setPovi_ordinary_mentalstatus("一般心理状况");
		ht.setPovi_bloodpressure_high(120);
		ht.setPovi_bloodpressure_low(70);
		ht.setPovi_has_breast_abnormal(1);
		ht.setPovi_breast_abnormal("");
		ht.setPovi_has_lochia_abnormal(2);
		ht.setPovi_lochia_abnormal("恶露异常");
		ht.setPovi_has_uterus_abnormal(1);
		ht.setPovi_uterus_abnormal("");
		ht.setPovi_has_wound_abnormal(2);
		ht.setPovi_wound_abnormal("伤口异常");
		ht.setPovi_other_abnormal("其他异常情况");
		ht.setPovi_is_abnormal(2);
		ht.setPovi_abnormal("此次检查有异常");
		ht.setPovi_guide("1,3,6");
		ht.setPovi_other_guide("其他指导");
		ht.setPovi_need_transfer(2);
		ht.setPovi_transfer_reason("孕妇血压偏低");
		ht.setPovi_transfer_hospital("甘肃省人民医院妇产科");
		ht.setPovi_next_visit_date("2011-8-15");
		ht.setPovi_doctor("李医生");
		ht.insertPostnatalVisit();
		
		PostnatalVisit ht1 = new PostnatalVisit(getContext());
		ht1.selectPostnatalVisit(12345);
		assertEquals(ht1.getPovi_date(),"2011-8-3");
		assertEquals(ht1.getPovi_body_temprature(),37.0f);
		assertEquals(ht1.getPovi_ordinary_healthstatus(),"一般健康状况");
		assertEquals(ht1.getPovi_ordinary_mentalstatus(),"一般心理状况");
		assertEquals(ht1.getPovi_bloodpressure_high(),120);
		assertEquals(ht1.getPovi_bloodpressure_low(),70);
		assertEquals(ht1.getPovi_has_breast_abnormal(),1);
		assertEquals(ht1.getPovi_breast_abnormal(),"");
		assertEquals(ht1.getPovi_has_lochia_abnormal(),2);
		assertEquals(ht1.getPovi_lochia_abnormal(),"恶露异常");
		assertEquals(ht1.getPovi_has_uterus_abnormal(),1);
		assertEquals(ht1.getPovi_uterus_abnormal(),"");
		assertEquals(ht1.getPovi_has_wound_abnormal(),2);
		assertEquals(ht1.getPovi_wound_abnormal(),"伤口异常");
		assertEquals(ht1.getPovi_other_abnormal(),"其他异常情况");
		assertEquals(ht1.getPovi_is_abnormal(),2);
		assertEquals(ht1.getPovi_abnormal(),"此次检查有异常");
		assertEquals(ht1.getPovi_guide(),"1,3,6");
		assertEquals(ht1.getPovi_other_guide(),"其他指导");
		assertEquals(ht1.getPovi_need_transfer(),2);
		assertEquals(ht1.getPovi_transfer_reason(),"孕妇血压偏低");
		assertEquals(ht1.getPovi_transfer_hospital(),"甘肃省人民医院妇产科");
		assertEquals(ht1.getPovi_next_visit_date(),"2011-8-15");
		assertEquals(ht1.getPovi_doctor(),"李医生");
		
		ht1.delectPostnatalVisit(12345);
		Cursor cursor = getContext().getContentResolver().query(CONTENT_URI_TB18, null, POVI_COLUMN1+"="+12345+"", null, null);
		assertEquals(0, cursor.getCount());
	}
	
	public void testLastPostnatalCheck(){
		LastPostnatalCheck ht = new LastPostnatalCheck(getContext());
		ht.setLapc_id(12345);
		ht.setLapc_date("2011-10-15");
//		ht.setLapc_body_temprature(36.5f);
		ht.setLapc_ordinary_healthstatus("一般健康状况");
		ht.setLapc_ordinary_mentalstatus("一半心理状况");
		ht.setLapc_bloodpressure_high(125);
		ht.setLapc_bloodpressure_low(65);
		ht.setLapc_has_breast_abnormal(2);
		ht.setLapc_breast_abnormal("乳房异常");
		ht.setLapc_has_lochia_abnormal(1);
		ht.setLapc_lochia_abnormal("");
		ht.setLapc_has_uterus_abnormal(2);
		ht.setLapc_uterus_abnormal("子宫异常");
		ht.setLapc_has_wound_abnormal(1);
		ht.setLapc_wound_abnormal("");
		ht.setLapc_other_abnormal("其他检查");
		ht.setLapc_has_recovered(2);
		ht.setLapc_remaining("未恢复的病情");
		ht.setLapc_guide("3,4");
		ht.setLapc_other_guide("其他指导");
		ht.setLapc_need_transfer(1);
		ht.setLapc_transfer_reason("");
		ht.setLapc_transfer_hospital("");
		ht.setLapc_doctor("李医生");
		ht.insertLastPostnatalCheck();
		
		LastPostnatalCheck ht1 = new LastPostnatalCheck(getContext());
		ht1.selectLastPostnatalCheck(12345);
		assertEquals(ht1.getLapc_date(),"2011-10-15");
//		assertEquals(ht1.getLapc_body_temprature(),36.5f);
		assertEquals(ht1.getLapc_ordinary_healthstatus(),"一般健康状况");
		assertEquals(ht1.getLapc_ordinary_mentalstatus(),"一半心理状况");
		assertEquals(ht1.getLapc_bloodpressure_high(),125);
		assertEquals(ht1.getLapc_bloodpressure_low(),65);
		assertEquals(ht1.getLapc_has_breast_abnormal(),2);
		assertEquals(ht1.getLapc_breast_abnormal(),"乳房异常");
		assertEquals(ht1.getLapc_has_lochia_abnormal(),1);
		assertEquals(ht1.getLapc_lochia_abnormal(),"");
		assertEquals(ht1.getLapc_has_uterus_abnormal(),2);
		assertEquals(ht1.getLapc_uterus_abnormal(),"子宫异常");
		assertEquals(ht1.getLapc_has_wound_abnormal(),1);
		assertEquals(ht1.getLapc_wound_abnormal(),"");
		assertEquals(ht1.getLapc_other_abnormal(),"其他检查");
		assertEquals(ht1.getLapc_has_recovered(),2);
		assertEquals(ht1.getLapc_remaining(),"未恢复的病情");
		assertEquals(ht1.getLapc_guide(),"3,4");
		assertEquals(ht1.getLapc_other_guide(),"其他指导");
		assertEquals(ht1.getLapc_need_transfer(),1);
		assertEquals(ht1.getLapc_transfer_reason(),"");
		assertEquals(ht1.getLapc_transfer_hospital(),"");
		assertEquals(ht1.getLapc_doctor(),"李医生");
		
		ht1.delectLastPostnatalCheck(12345);
		Cursor cursor = getContext().getContentResolver().query(CONTENT_URI_TB19, null, LAPC_COLUMN1+"="+12345+"", null, null);
		assertEquals(0, cursor.getCount());
	}
}
